package com.jwds.digital.bios.business.api.controller.belt;

import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltRoutePerformanceDayRespVO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltRoutePerformanceHourRespVO;
import com.jwds.digital.bios.business.service.service.belt.IBeltRoutePerformanceMonthService;
import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltRoutePerformanceMonthReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltRoutePerformanceMonthRespVO;
import com.jwds.tdc.framework.application.lib.BaseResponse;
import com.jwds.tdc.framework.application.lib.page.PageRequest;
import com.jwds.tdc.framework.application.lib.page.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * 线路效能月表 前端控制器
 *
 * @author 林柏云
 * @date 2024-10-24
 */
@Slf4j
@Api(tags = "线路效能月表")
@RestController
@RequestMapping("/belt/route/performance/month")
public class BeltRoutePerformanceMonthController {

  @Resource
  private IBeltRoutePerformanceMonthService service;

  @GetMapping("/{id}")
  @ApiOperation(value = "根据id查询")
  public BaseResponse<BeltRoutePerformanceMonthRespVO> queryById(@PathVariable("id") Long id) {
    BeltRoutePerformanceMonthRespVO respVo = service.queryById(id);
    return BaseResponse.success(respVo);
  }

  @PostMapping("/list")
  @ApiOperation(value = "分页查询")
  public BaseResponse<PageResponse<BeltRoutePerformanceMonthRespVO>> page(@Valid @RequestBody PageRequest<BeltRoutePerformanceMonthReqDTO> pageRequest) {
    PageResponse<BeltRoutePerformanceMonthRespVO> respVoPage = service.page(pageRequest);
    return BaseResponse.success(respVoPage);
  }

  @PostMapping("/all")
  @ApiOperation(value = "列表查询")
  public BaseResponse<List<BeltRoutePerformanceMonthRespVO>> list(@Valid @RequestBody BeltRoutePerformanceMonthReqDTO reqDto) {
    List<BeltRoutePerformanceMonthRespVO> respVoList = service.list(reqDto);
    return BaseResponse.success(respVoList);
  }

  @PostMapping("/")
  @ApiOperation(value = "新增")
  public BaseResponse<?> add(@Validated @RequestBody BeltRoutePerformanceMonthReqDTO reqDto) {
    service.add(reqDto);
    return BaseResponse.success();
  }

  @PostMapping("/batch")
  @ApiOperation(value = "批量新增")
  public BaseResponse<?> batchAdd(@Validated @RequestBody List<BeltRoutePerformanceMonthReqDTO> reqDtoList) {
    service.batchAdd(reqDtoList);
    return BaseResponse.success();
  }

  @PutMapping("/")
  @ApiOperation(value = "更新对象")
  public BaseResponse<?> update(@Validated @RequestBody BeltRoutePerformanceMonthReqDTO reqDto) {
    service.update(reqDto);
    return BaseResponse.success();
  }

  @DeleteMapping("/{id}")
  @ApiOperation(value = "删除对象")
  public BaseResponse<?> delete(@PathVariable("id") Long id) {
    service.delete(id);
    return BaseResponse.success();
  }

  @DeleteMapping("/batch")
  @ApiOperation(value = "批量删除对象")
  public BaseResponse<?> batchDelete(@RequestBody List<Long> ids) {
    service.batchDelete(ids);
    return BaseResponse.success();
  }

  @GetMapping("/LineEfficiencyMonth/{routeId}")
  @ApiOperation(value = "线路效能月消息")
  public BaseResponse<BeltRoutePerformanceMonthRespVO> getLineEfficiencyMonth(@PathVariable("routeId") Long routeId){
    return BaseResponse.success(service.getLineEfficiencyMonth(routeId));
  }

  @ApiOperation(value = "线路效能月皮带信息详细查询")
  @GetMapping("/info/{id}")
  public BaseResponse<List<Map<String, Object>>> getBeltInfo(@PathVariable Long id) {
    List<Map<String, Object>> map = service.getBeltInfoById(id);
    return BaseResponse.success(map);
  }

}
